import java.util.*;

public class MySort1 {

    public static void main(String[] args) {
        String[] toSort = {"aaa:10:1:1",
                "ccc:30:3:4",
                "bbb:50:4:5",
                "ddd:20:5:3",
                "eee:40:2:20"};
        int x;
        int [] tmp = new int[toSort.length];
        String[] m;
        System.out.println("Before sort:");
        for (String str : toSort) {
            System.out.println(str);
        }
        for (int i = 0; i < toSort.length; i++) {
            m = toSort[i].split(":");
            tmp[i] = Integer.parseInt(m[1]);
        }
        Arrays.sort(tmp);

        System.out.println("After sort:");
        for (int i = 0; i < toSort.length; i++) {
            for (int j = 0; j < tmp.length; j++) {
                m = toSort[j].split(":");
                x= Integer.parseInt(m[1]);
                if(x==tmp[i])
                    System.out.println(toSort[j]);
            }
        }
    }
}
